package com.data.web.config;

import com.data.biz.constant.TimeFormatConstant;
import com.data.biz.domain.*;
import com.data.biz.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;

@Configuration
public class DataTest {

    @Autowired
    private FunctionModelMapper functionModelMapper;

    @Autowired
    private WindPointMapper windPointMapper;

    @Autowired
    private DipDataMapperEx dipDataMapperEx;

    @Autowired
    private DipDayMapper dipDayMapper;


    @Autowired
    private AccDataMapperEx accDataMapperEx;

    @Autowired
    private DipDataMapper dipDataMapper;

    @Autowired
    private AccDataMapper accDataMapper;

    @Autowired
    private  TableCountMapper tableCountMapper;

//    @PostConstruct
    public void testDayData() throws ParseException {
        DipDay dipDay = new DipDay();
        dipDay.setxMax(new BigDecimal(0));
        dipDayMapper.insert(dipDay);
//        TableCount count = new TableCount();
//        count.setPointId(3);
//        count.setFunctionId(2);
//        count.setIsDelete((short)0);
//        tableCountMapper.insert(count);
    }

    //    @PostConstruct
    public void editDataTime() throws ParseException {
        Long timea = TimeFormatConstant.formatSec.parse("2025-02-15 09:53:30").getTime();
        Long timeb = TimeFormatConstant.formatSec.parse("2025-01-15 09:53:30").getTime();

        Long gap = timea - timeb;

        DipDataExample example = new DipDataExample();
        DipDataExample.Criteria criteria = example.createCriteria();
        List<DipData> list = dipDataMapper.selectByExample(example);
        for (DipData data : list) {
            Long time = data.getCreateTime().getTime() + gap;
            data.setCreateTime(new Date(time));
            dipDataMapper.updateByPrimaryKeySelective(data);
        }
        System.out.println();
    }


}

